package com.weike.yuanding.intercepter;

import com.weike.yuanding.utils.BaseContext;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

/**
 * @ClassName: UserIdIntercepater
 * @Author: YuanDing
 * @Date: 2025/4/3 23:18
 * @Description:
 */

@Component
public class UserIdInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        BaseContext.userId.set(request.getHeader("userId"));

        return true;
    }
}
